<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>按钮</button>

    <button id="btn1">刷新</button>
    <button id="btn2">后退</button>
    <button id="btn3">前进</button>
    <button id="btn4">连续前进</button>
    <button id="btn5">连续后退</button>
    <script>
        // 1.获取当前页的href，host信息，并在5秒后自动跳转到百度首页 (https://www.baidu.com)
        const btn = document.querySelector("button")
        btn.onclick = function () {
            console.log("href：" + location.href)
            console.log("host：" + location.host)
            console.log("hostname：" + window.location.hostname)
            console.log("port：" + window.location.port)
            setTimeout(function () {
                window.location.href = "https://www.baidu.com"
            }, 5000)
        }
        btn1.onclick = function() {
            window.history.go(0)
        }
        btn2.onclick = function() {
            window.history.go(-1)
        }
        btn3.onclick = function() {
            window.history.go(1)
        }
        btn4.onclick = function() {
            window.history.go(2)
        }
        btn5.onclick = function() {
            window.history.go(-2)
        }
    </script>
</body>
</html>